package validator

import (
	"github.com/go-playground/validator/v10"
	"regexp"
)

//这是v10的写法，v8需要参照上面的博客
func TopicUrl(fl validator.FieldLevel) bool {
	if url, ok := fl.Field().Interface().(string); ok {
		if matched, _ := regexp.MatchString(`\w{4,10}`, url); matched {
			return true
		}
	}
	return false
}
